Skip to content

Genericize Test Functions#2177

Merged
wpaulino merged 3 commits intolightningdevkit:mainfrom
TheBlueMatt:2023-04-test-function-generics
Apr 17, 2023
Merged

Genericize Test Functions#2177
wpaulino merged 3 commits intolightningdevkit:mainfrom
TheBlueMatt:2023-04-test-function-generics

Conversation

@TheBlueMatt
Copy link
Copy Markdown
Collaborator

This is the prefactors from #2111 which just set us up to have more functions in testing, avoiding more macros in tests.

In the coming commits we'll add some additional complexity to the
event handling flows, so best to DRY them up before we get there.
@TheBlueMatt TheBlueMatt changed the title 2023 04 test function generics Genericize Test Functions Apr 12, 2023
@TheBlueMatt
Copy link
Copy Markdown
Collaborator Author

Assigning val and wilmer cause y'all are already on 2111.

@TheBlueMatt TheBlueMatt added this to the 0.0.115 milestone Apr 12, 2023
&'a test_utils::TestFeeEstimator, &'a test_utils::TestRouter<'a>,
&'a test_utils::TestLogger>;

struct ANodeHolder<'a, P: Persist<InMemorySigner>> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we migrate the BackgroundProcessor utils as well so they can use functional_test_utils?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but its a bit big, would have to add a bunch of new accessors and maybe do the chain tracking via the trait too.

@TheBlueMatt TheBlueMatt force-pushed the 2023-04-test-function-generics branch from 1be3caf to db9cd01 Compare April 12, 2023 20:03
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 12, 2023

Codecov Report

❌ Patch coverage is 98.27586% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.34%. Comparing base (157af6e) to head (cfb9eb9).
⚠️ Report is 6169 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/functional_test_utils.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2177      +/-   ##
==========================================
- Coverage   91.36%   91.34%   -0.02%     
==========================================
  Files         102      102              
  Lines       50369    50401      +32     
  Branches    50369    50401      +32     
==========================================
+ Hits        46018    46040      +22     
- Misses       4351     4361      +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@valentinewallace valentinewallace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after @wpaulino takes a look

In our test utilities, we generally refer to a `Node` struct which
holds a `ChannelManager` and a number of other structs. However, we
use the same utilities in benchmarking, where we have a different
`Node`-like struct. This made moving from macros to functions
entirely impossible, as we end up needing multiple types in a given
context.

Thus, here, we take the pain and introduce some wrapper traits
which encapsulte what we need from `Node`, swapping some of our
macros to functions.
This marginally reduces the quantity of code compiled in tests
further.
@TheBlueMatt TheBlueMatt force-pushed the 2023-04-test-function-generics branch from db9cd01 to cfb9eb9 Compare April 13, 2023 18:40
@TheBlueMatt
Copy link
Copy Markdown
Collaborator Author

Squashed with typo fixes:

$ git diff-tree -U1 db9cd012 cfb9eb96
diff --git a/lightning/src/ln/functional_test_utils.rs b/lightning/src/ln/functional_test_utils.rs
index d35d286bb..f8ccce058 100644
--- a/lightning/src/ln/functional_test_utils.rs
+++ b/lightning/src/ln/functional_test_utils.rs
@@ -1566,3 +1566,3 @@ macro_rules! commitment_signed_dance {
 /// Runs the commitment_signed dance after the initial commitment_signed is delivered through to
-/// the initiator's `revoke_and_ack` resposne. i.e. [`do_main_commitment_signed_dance`] plus the
+/// the initiator's `revoke_and_ack` response. i.e. [`do_main_commitment_signed_dance`] plus the
 /// `revoke_and_ack` response to it.
@@ -1579,3 +1579,3 @@ pub fn commitment_signed_dance_through_cp_raa(node_a: &Node<'_, '_, '_>, node_b:
 /// been delivered, this method picks up and delivers the response `revoke_and_ack` and
-/// `commitment_signed`, returning the receipient's `revoke_and_ack` and any extra message it may
+/// `commitment_signed`, returning the recipient's `revoke_and_ack` and any extra message it may
 /// have included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants